#ifndef __V4L2_CAMERA__
#define __V4L2_CAMERA__

#include <cstdlib>
#include <cstring>
#include <sys/time.h>

#include "v4l2.h"

class V4L2Camera {
private:
    CamId fd;
    char device[20];
    uint width, height;
    bool capturing = false;
    bool getting_frame = false;

    ImgBuf* img;
    
    ImgBuf* buffer;
    struct v4l2_buffer readbuffer;

    void init(const char* device, uint width, uint height);
public:
    V4L2Camera(const char* device);
    V4L2Camera(const char* device, uint width, uint height);
    ~V4L2Camera();

    
    void start();
    void stop();

    ImgBuf* get_jpg_frame();
    
    void release_frame();
    
    void info();
    // void test_time();
};

#endif  // __V4L2_CAMERA__